<?php
class PM_o
{
    public static function __index( $room_id , $user_id , $mop_uid , $card_number , $is_pao , $pao_uid , $db_connect ){
        //取出房间信息
        $room_info  = $db_connect->select('*')->from('tt_room')->where("room_id= '". $room_id ."' ")->row();
        //取出该房间对应的当前申请胡牌的用户牌面信息
        $card_info  = $db_connect->select('*')->from('tt_room_card')->where("uid = '". $user_id ."' and jid = '". $room_info['room_js'] ."' and rid= '". $room_id ."' ")->row();
        //进行一次用户胡牌再判断(如果有跑，跑牌者是自己才需要进行基础牌操作，否则就是破跑胡)
        $default_huxi = PHZ_Tools::__get_user_xpAndKanzi_Huxi( $room_id , $user_id );
        if( $is_pao == 1 && $pao_uid == $user_id ){
            $paiNumberArray = PHZ_Card::__cardSpGETPaoSP__AND_TEMP_CARD_NUMBER( $card_info['sp'] );//进行临时牌解析与查询
            if( $paiNumberArray[0] != "" && $paiNumberArray[1] != 0 ){
                $default_huxi = $default_huxi + $paiNumberArray[2];//累计被去掉的息
                $canHu        = PHZ_CanHu::__isCan_Hu_Pai( $default_huxi, $paiNumberArray[0] , $paiNumberArray[1] , -1 , $room_info );//跑胡判断
            }else{
                $canHu['canHu'] = false;
            }
        }else{
            $canHu = PHZ_CanHu::__isCan_Hu_Pai($default_huxi, $card_info['sp'], $card_number , 1 , $room_info  );//普通胡判断
        }
        if( $canHu['canHu'] == true ){
            if( $user_id == $mop_uid ){
                $SOR_END = PHZ_Scoring::__game_Single_END( $room_info , $canHu['huXi'] , $user_id , 0 , $card_number , 2 , $db_connect );//自摸
            }else{
                $SOR_END = PHZ_Scoring::__game_Single_END( $room_info , $canHu['huXi'] , $user_id , 0 , $card_number , 1 , $db_connect );//公炮
            }
            //成功胡牌后，该房当前所有吃碰胡属性归0
            PHZ_Tools::__set_room_alluser_hu_chi_peng_0( $room_id , $db_connect );
        }
        return true;
    }
}